import React, { Component } from "react";
import Mouse from "./Mouse";
const Position = (props) => {
  return (
    <div>
      <p>x坐标为：{props.x}</p>
      <p>y坐标为：{props.y}</p>
    </div>
  );
};
export default class App extends Component {
  render() {
    return (
      <div>
        <Mouse>
          {(mouse) => {
            return (
              <div>
                <p>x坐标为：{mouse.x}</p>
                <p>y坐标为：{mouse.y}</p>
              </div>
            );
          }}
        </Mouse>

        <Mouse>{(mouse) => Position(mouse)}</Mouse>

        <Mouse>{(mouse) => <Position {...mouse} />}</Mouse>

        <Mouse>
          {(mouse) => {
            return (
              <div>
                <img
                  style={{
                    position: "absolute",
                    left: mouse.x + "px",
                    top: mouse.y + "px",
                  }}
                  src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.uusucai.com%2Fd%2Ffile%2Fweb%2Fgif%2F2015%2F06%2F21%2Fc57a5f87fe8d074a81660caeb02c24a6.gif&refer=http%3A%2F%2Fwww.uusucai.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1668565545&t=e052aebc9be3de38a9a308a39d164fa8"
                />
              </div>
            );
          }}
        </Mouse>
      </div>
    );
  }
}
